package com.csinc.generate.core.database.read;

import com.csinc.generate.core.database.exception.GenerationRunTimeException;
import com.csinc.generate.core.database.read.impl.ReadTableForMysqlImpl;

import static com.csinc.generate.core.constant.GenCoreConstant.MYSQL5;
import static com.csinc.generate.core.constant.GenCoreConstant.MYSQL8;


/**
 * 读取库的工厂
 * Create By 郭金宝 on 2018/7/23.<br>
 */
public class ReadTableFactory {
    public static IReadTable getReadTable(String dbType) {
        if (MYSQL5.equalsIgnoreCase(dbType) || MYSQL8.equalsIgnoreCase(dbType)) {
            return new ReadTableForMysqlImpl();
        }
        throw new GenerationRunTimeException("数据库不支持");
    }

    public static String getDeiver(String dbType) {
        if (MYSQL5.equalsIgnoreCase(dbType)) {
            return "com.mysql.jdbc.Driver";
        }
        if (MYSQL8.equalsIgnoreCase(dbType)) {
            return "com.mysql.cj.jdbc.Driver";
        }
        throw new GenerationRunTimeException("数据库不支持");
    }
}
